<?php
/**
* @version		$Id: mod_login.php 10381 2008-06-01 03:35:53Z pasamio $
* @package		Joomla
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/


// no direct access
defined('_JEXEC') or die('Restricted access');

// Include the syndicate functions only once
$type = $params->get( 'type' );
//echo $type;
$position = $params->get('style');

$user = &JFactory::getUser();
if($user->guest) // гость получает доступ только к не закрытым
	$access = ' AND access=0 '; 
if($user->gid > 22) // специальный пользователь получает доступ ко всем пунктам
	$access = '';
if($user->gid >= 18 && $user->gid < 22)
	$access =' AND access<2 ';

$db = &JFactory::getDBO();
$query = "SELECT * FROM #__menu WHERE menutype='$type' AND published>0 AND parent=0 ".$access." ORDER BY ordering ASC";
//echo $query;
//echo $user->gid;
$db->setQuery($query);
$menu_level_0 = $db->loadObjectList();
global $mainframe,$Itemid;
$router		= &$mainframe->getRouter();


switch ($position){

	case 1:
		echo '<ul class="menu">';
            					
		
		foreach($menu_level_0 as $k=>$item)
		{
			if($item->type == 'url')
				$url = stripslashes(htmlspecialchars($item->link));
			else
			//	if (intval($mainframe->getCfg('sef')) == 1)
			//		$url = stripslashes(htmlspecialchars($item->alias));
			//	else
					$url =  stripslashes(htmlspecialchars($item->link))."&Itemid=".$item->id;
					
			if($item->type == 'separator')
				$url = '#';
		//	if($item->home == 1 && intval($mainframe->getCfg('sef')) != 1)
		//		$url = '/nova/';
			$id = '';
			
			
			//$url .= $Itemid;
			
			$class ='';
			if($item->id == $Itemid)
				$class = 'active';
			echo '<li  class="'.$class.'"><a href="'.$url.'">'.$item->name.'</a></li>';

			
			
		}
		echo '</ul>';
		break;
	case 2:		
		//if($user->gid>17)
		//echo '<div class="componentheader">'.$user->name.'</div>';
		//echo '<h3>'.$user->name.'</h3>';
		echo '<ul class="catalog_list">';           					
		
		foreach($menu_level_0 as $k=>$item)
		{
			if($item->type == 'url')
				$url = stripslashes(htmlspecialchars($item->link));
			else
				//if (intval($mainframe->getCfg('sef')) == 1)
				//	$url = stripslashes(htmlspecialchars($item->alias));
			//	else
					$url =  stripslashes(htmlspecialchars($item->link))."&Itemid=".$item->id;
					
			if($item->type == 'separator')
				$url = '#';
		//	if($item->home == 1 && intval($mainframe->getCfg('sef')) != 1)
		//		$url = '/nova/';
			$id = '';
			
			
			//$url .= $Itemid;
			
			$class ='';
			if(($k+1) % 2 != 0)
				$class = 'odd';
			echo '<li  class="'.$class.'"><a href="'.JRoute::_($url).'">'.$item->name.'</a></li>';

			
			
		}
		echo '</ul>';		
		
		break;
	case 4:		
		if($user->gid>17)
		//echo '<div class="componentheader">'.$user->name.'</div>';
		echo '<h3 style="color:#7E0101;margin-top:10px;">'.$user->name.'</h3>';
		echo '<ul class="catalog_list">';           					
		
		foreach($menu_level_0 as $k=>$item)
		{
			if($item->type == 'url')
				$url = stripslashes(htmlspecialchars($item->link));
			else
				//if (intval($mainframe->getCfg('sef')) == 1)
				//	$url = stripslashes(htmlspecialchars($item->alias));
			//	else
					$url =  stripslashes(htmlspecialchars($item->link))."&Itemid=".$item->id;
					
			if($item->type == 'separator')
				$url = '#';
		//	if($item->home == 1 && intval($mainframe->getCfg('sef')) != 1)
		//		$url = '/nova/';
			$id = '';
			
			
			//$url .= $Itemid;
			
			$class ='';
			if(($k+1) % 2 != 0)
				$class = 'odd';
			echo '<li  class="'.$class.'"><a href="'.JRoute::_($url).'">'.$item->name.'</a></li>';

			
			
		}
		echo '</ul>';		
		
		break;
	case 3:
			
		echo '<ul class="footer_menu">';           					
		
		foreach($menu_level_0 as $k=>$item)
		{
			if($item->type == 'url')
				$url = stripslashes(htmlspecialchars($item->link));
			else
			//	if (intval($mainframe->getCfg('sef')) == 1)
			//		$url = stripslashes(htmlspecialchars($item->alias));
			//	else
					$url =  stripslashes(htmlspecialchars($item->link))."&Itemid=".$item->id;
					
			if($item->type == 'separator')
				$url = '#';
		//	if($item->home == 1 && intval($mainframe->getCfg('sef')) != 1)
		//		$url = '/nova/';
			$id = '';
			
			
			//$url .= $Itemid;
			
			$class ='';
			if($k== 0)
				echo '<li><a href="'.JRoute::_($url).'">'.$item->name.'</a></li>';
			else
				echo '<li>&nbsp;|&nbsp;<a href="'.JRoute::_($url).'">'.$item->name.'</a></li>';

			
			
		}
		echo '</ul>';	
		break;
		
}
?>
